package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.FigureEventRequest;
import cn.stylefeng.guns.modular.business.service.FigureEventService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 人物相关事件表控制器
 *
 * @author zhangyaowen
 * @date 2021/10/25 16:46
 */
@RestController
@ApiResource(name = "人物相关事件表")
public class FigureEventController {

    @Resource
    private FigureEventService figureEventService;

    /**
     * 添加
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "添加", path = "/figureEvent/add")
    public ResponseData add(@RequestBody @Validated(FigureEventRequest.add.class) FigureEventRequest figureEventRequest) {
        figureEventService.add(figureEventRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "删除", path = "/figureEvent/delete")
    public ResponseData delete(@RequestBody @Validated(FigureEventRequest.delete.class) FigureEventRequest figureEventRequest) {
        figureEventService.del(figureEventRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @PostResource(name = "编辑", path = "/figureEvent/edit")
    public ResponseData edit(@RequestBody @Validated(FigureEventRequest.edit.class) FigureEventRequest figureEventRequest) {
        figureEventService.edit(figureEventRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看详情
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "查看详情", path = "/figureEvent/detail")
    public ResponseData detail(@Validated(FigureEventRequest.detail.class) FigureEventRequest figureEventRequest) {
        return new SuccessResponseData(figureEventService.detail(figureEventRequest));
    }

    /**
     * 获取列表
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "获取列表", path = "/figureEvent/list")
    public ResponseData list(FigureEventRequest figureEventRequest) {
        return new SuccessResponseData(figureEventService.findList(figureEventRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author zhangyaowen
     * @date 2021/10/25 16:46
     */
    @GetResource(name = "分页查询", path = "/figureEvent/page")
    public ResponseData page(String name) {
        FigureEventRequest figureEventRequest = new FigureEventRequest();
        figureEventRequest.setFigureName(name);
        return new SuccessResponseData(figureEventService.findPage(figureEventRequest));
    }

    /**
     * 获取河道管理详情
     *
     * @param id
     * @return
     */
    @GetResource(name = "人物相关事件", path = "/figureEvent/toReview")
    public ResponseData toReview(String id) {
        return new SuccessResponseData(figureEventService.toReview(id));
    }

}